#include "GroupNode.h"

namespace ds {

GroupNode::~GroupNode(void) {
	Nodes::iterator it = m_Nodes.begin();
	while ( it != m_Nodes.end() ) {
		delete (*it);
		it = m_Nodes.erase(it);
	}
}

void GroupNode::onCreateDevice() {
	for ( size_t i = 0; i < m_Nodes.size();++i ) {
		m_Nodes[i]->onCreateDevice();
	}
}

void GroupNode::onResetDevice() {
	for ( size_t i = 0; i < m_Nodes.size();++i ) {
		m_Nodes[i]->onResetDevice();
	}
}

void GroupNode::onLostDevice() {
	for ( size_t i = 0; i < m_Nodes.size();++i ) {
		m_Nodes[i]->onLostDevice();
	}
}

void GroupNode::onDestroyDevice() {
	for ( size_t i = 0; i < m_Nodes.size();++i ) {
		m_Nodes[i]->onDestroyDevice();
	}
}

// basic methods
void GroupNode::init()  {
	for ( size_t i = 0; i < m_Nodes.size();++i ) {
		m_Nodes[i]->init();
	}
}

void GroupNode::loadContent(ResManager& resourceManager) {
	for ( size_t i = 0; i < m_Nodes.size();++i ) {
		m_Nodes[i]->loadContent(resourceManager);
	}
}

void GroupNode::update(float elapsed) {
	for ( size_t i = 0; i < m_Nodes.size();++i ) {
		m_Nodes[i]->update(elapsed);
	}
}

// rendering
void GroupNode::prepareRendering() {
	for ( size_t i = 0; i < m_Nodes.size();++i ) {
		m_Nodes[i]->prepareRendering();
	}
}

void GroupNode::draw() {
	for ( size_t i = 0; i < m_Nodes.size();++i ) {
		m_Nodes[i]->draw();
	}
}

void GroupNode::postRendering() {
	for ( size_t i = 0; i < m_Nodes.size();++i ) {
		m_Nodes[i]->postRendering();
	}
}


}
